<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Gem::Commands::CertCommand - rubygems: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../Command.html">Gem::Command</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-build">#build</a>
    <li ><a href="#method-i-certificates_matching">#certificates_matching</a>
    <li ><a href="#method-i-check_openssl">#check_openssl</a>
    <li ><a href="#method-i-execute">#execute</a>
    <li ><a href="#method-i-load_default_cert">#load_default_cert</a>
    <li ><a href="#method-i-load_default_key">#load_default_key</a>
    <li ><a href="#method-i-open_cert">#open_cert</a>
    <li ><a href="#method-i-open_private_key">#open_private_key</a>
    <li ><a href="#method-i-re_sign_cert">#re_sign_cert</a>
    <li ><a href="#method-i-sign">#sign</a>
    <li ><a href="#method-i-valid_email-3F">#valid_email?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Gem::Commands::CertCommand">
    <h1 id="class-Gem::Commands::CertCommand" class="class">
      class Gem::Commands::CertCommand
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="../Command.html#method-c-new"><code>Gem::Command::new</code></a>
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
  <span class="ruby-keyword">super</span> <span class="ruby-string">&quot;cert&quot;</span>, <span class="ruby-string">&quot;Manage RubyGems certificates and signing settings&quot;</span>,
        <span class="ruby-value">:add</span> <span class="ruby-operator">=&gt;</span> [], <span class="ruby-value">:remove</span> <span class="ruby-operator">=&gt;</span> [], <span class="ruby-value">:list</span> <span class="ruby-operator">=&gt;</span> [], <span class="ruby-value">:build</span> <span class="ruby-operator">=&gt;</span> [], <span class="ruby-value">:sign</span> <span class="ruby-operator">=&gt;</span> []

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-a&quot;</span>, <span class="ruby-string">&quot;--add CERT&quot;</span>,
             <span class="ruby-string">&quot;Add a trusted certificate.&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cert_file</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:add</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">open_cert</span>(<span class="ruby-identifier">cert_file</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-l&quot;</span>, <span class="ruby-string">&quot;--list [FILTER]&quot;</span>,
             <span class="ruby-string">&quot;List trusted certificates where the&quot;</span>,
             <span class="ruby-string">&quot;subject contains FILTER&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filter</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">filter</span> <span class="ruby-operator">||=</span> <span class="ruby-string">&quot;&quot;</span>

    <span class="ruby-identifier">options</span>[<span class="ruby-value">:list</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">filter</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-r&quot;</span>, <span class="ruby-string">&quot;--remove FILTER&quot;</span>,
             <span class="ruby-string">&quot;Remove trusted certificates where the&quot;</span>,
             <span class="ruby-string">&quot;subject contains FILTER&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filter</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:remove</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">filter</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-b&quot;</span>, <span class="ruby-string">&quot;--build EMAIL_ADDR&quot;</span>,
             <span class="ruby-string">&quot;Build private key and self-signed&quot;</span>,
             <span class="ruby-string">&quot;certificate for EMAIL_ADDR&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">email_address</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:build</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">email_address</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-C&quot;</span>, <span class="ruby-string">&quot;--certificate CERT&quot;</span>,
             <span class="ruby-string">&quot;Signing certificate for --sign&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cert_file</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert</span>] = <span class="ruby-identifier">open_cert</span>(<span class="ruby-identifier">cert_file</span>)
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert_file</span>] = <span class="ruby-identifier">cert_file</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-K&quot;</span>, <span class="ruby-string">&quot;--private-key KEY&quot;</span>,
             <span class="ruby-string">&quot;Key for --sign or --build&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key_file</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>] = <span class="ruby-identifier">open_private_key</span>(<span class="ruby-identifier">key_file</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-A&quot;</span>, <span class="ruby-string">&quot;--key-algorithm ALGORITHM&quot;</span>,
             <span class="ruby-string">&quot;Select which key algorithm to use for --build&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:key_algorithm</span>] = <span class="ruby-identifier">algorithm</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-s&quot;</span>, <span class="ruby-string">&quot;--sign CERT&quot;</span>,
             <span class="ruby-string">&quot;Signs CERT with the key from -K&quot;</span>,
             <span class="ruby-string">&quot;and the certificate from -C&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cert_file</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>, <span class="ruby-node">&quot;#{cert_file}: does not exist&quot;</span> <span class="ruby-keyword">unless</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span> <span class="ruby-identifier">cert_file</span>

    <span class="ruby-identifier">options</span>[<span class="ruby-value">:sign</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">cert_file</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-d&quot;</span>, <span class="ruby-string">&quot;--days NUMBER_OF_DAYS&quot;</span>,
             <span class="ruby-string">&quot;Days before the certificate expires&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">days</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:expiration_length_days</span>] = <span class="ruby-identifier">days</span>.<span class="ruby-identifier">to_i</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-R&quot;</span>, <span class="ruby-string">&quot;--re-sign&quot;</span>,
             <span class="ruby-string">&quot;Re-signs the certificate from -C with the key from -K&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resign</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:resign</span>] = <span class="ruby-identifier">resign</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build</span><span
                                class="method-args">(email)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build</span>(<span class="ruby-identifier">email</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">valid_email?</span>(<span class="ruby-identifier">email</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandLineError</span>, <span class="ruby-node">&quot;Invalid email address #{email}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">key</span>, <span class="ruby-identifier">key_path</span> = <span class="ruby-identifier">build_key</span>
  <span class="ruby-identifier">cert_path</span> = <span class="ruby-identifier">build_cert</span> <span class="ruby-identifier">email</span>, <span class="ruby-identifier">key</span>

  <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Certificate: #{cert_path}&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">key_path</span>
    <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Private Key: #{key_path}&quot;</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Don&#39;t forget to move the key file to somewhere private!&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-certificates_matching" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">certificates_matching</span><span
                                class="method-args">(filter) { |certificate, path| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="certificates_matching-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 186</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">certificates_matching</span>(<span class="ruby-identifier">filter</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">enum_for</span> <span class="ruby-identifier">__method__</span>, <span class="ruby-identifier">filter</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>

  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span>.<span class="ruby-identifier">trusted_certificates</span>.<span class="ruby-identifier">select</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">certificate</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">subject</span> = <span class="ruby-identifier">certificate</span>.<span class="ruby-identifier">subject</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-identifier">subject</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">index</span> <span class="ruby-identifier">filter</span>
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">sort_by</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">certificate</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">certificate</span>.<span class="ruby-identifier">subject</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">data</span>,<span class="ruby-operator">|</span> [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">data</span>] }
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">certificate</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">certificate</span>, <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_openssl" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_openssl</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="check_openssl-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_openssl</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">HAVE_OPENSSL</span>

  <span class="ruby-identifier">alert_error</span> <span class="ruby-string">&quot;OpenSSL library is required for the cert command&quot;</span>
  <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-execute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">execute</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="execute-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">execute</span>
  <span class="ruby-identifier">check_openssl</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:add</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">certificate</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">add_certificate</span> <span class="ruby-identifier">certificate</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:remove</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filter</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_certificates_matching</span> <span class="ruby-identifier">filter</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:list</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filter</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">list_certificates_matching</span> <span class="ruby-identifier">filter</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:build</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">email</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">build</span> <span class="ruby-identifier">email</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:resign</span>]
    <span class="ruby-identifier">re_sign_cert</span>(
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert</span>],
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert_file</span>],
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>]
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">sign_certificates</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:sign</span>].<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-load_default_cert" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">load_default_cert</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="load_default_cert-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 245</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">load_default_cert</span>
  <span class="ruby-identifier">cert_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_cert_path</span>
  <span class="ruby-identifier">cert</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">cert_file</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert</span>] = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">cert</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
  <span class="ruby-identifier">alert_error</span> \
    <span class="ruby-string">&quot;--certificate not specified and ~/.gem/gem-public_cert.pem does not exist&quot;</span>

  <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">CertificateError</span>
  <span class="ruby-identifier">alert_error</span> \
    <span class="ruby-string">&quot;--certificate not specified and ~/.gem/gem-public_cert.pem is not valid&quot;</span>

  <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-load_default_key" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">load_default_key</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="load_default_key-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 261</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">load_default_key</span>
  <span class="ruby-identifier">key_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_key_path</span>
  <span class="ruby-identifier">key</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">key_file</span>
  <span class="ruby-identifier">passphrase</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;GEM_PRIVATE_KEY_PASSPHRASE&quot;</span>]
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>] = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">passphrase</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
  <span class="ruby-identifier">alert_error</span> \
    <span class="ruby-string">&quot;--private-key not specified and ~/.gem/gem-private_key.pem does not exist&quot;</span>

  <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span><span class="ruby-operator">::</span><span class="ruby-constant">PKeyError</span>
  <span class="ruby-identifier">alert_error</span> \
    <span class="ruby-string">&quot;--private-key not specified and ~/.gem/gem-private_key.pem is not valid&quot;</span>

  <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-open_cert" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open_cert</span><span
                                class="method-args">(certificate_file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="open_cert-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 85</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open_cert</span>(<span class="ruby-identifier">certificate_file</span>)
  <span class="ruby-identifier">check_openssl</span>
  <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">certificate_file</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>, <span class="ruby-node">&quot;#{certificate_file}: does not exist&quot;</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">CertificateError</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>,
    <span class="ruby-node">&quot;#{certificate_file}: invalid X509 certificate&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-open_private_key" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">open_private_key</span><span
                                class="method-args">(key_file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="open_private_key-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 95</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open_private_key</span>(<span class="ruby-identifier">key_file</span>)
  <span class="ruby-identifier">check_openssl</span>
  <span class="ruby-identifier">passphrase</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;GEM_PRIVATE_KEY_PASSPHRASE&quot;</span>]
  <span class="ruby-identifier">key</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span>.<span class="ruby-identifier">read</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">key_file</span>), <span class="ruby-identifier">passphrase</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>,
    <span class="ruby-node">&quot;#{key_file}: private key not found&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">private?</span>
  <span class="ruby-identifier">key</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>, <span class="ruby-node">&quot;#{key_file}: does not exist&quot;</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span><span class="ruby-operator">::</span><span class="ruby-constant">PKeyError</span>, <span class="ruby-constant">ArgumentError</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>, <span class="ruby-node">&quot;#{key_file}: invalid RSA, DSA, or EC key&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-re_sign_cert" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">re_sign_cert</span><span
                                class="method-args">(cert, cert_path, private_key)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="re_sign_cert-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">re_sign_cert</span>(<span class="ruby-identifier">cert</span>, <span class="ruby-identifier">cert_path</span>, <span class="ruby-identifier">private_key</span>)
  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span><span class="ruby-operator">::</span><span class="ruby-constant">Signer</span>.<span class="ruby-identifier">re_sign_cert</span>(<span class="ruby-identifier">cert</span>, <span class="ruby-identifier">cert_path</span>, <span class="ruby-identifier">private_key</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">expired_cert_path</span>, <span class="ruby-identifier">new_expired_cert_path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">alert</span>(<span class="ruby-node">&quot;Your certificate #{expired_cert_path} has been re-signed&quot;</span>)
    <span class="ruby-identifier">alert</span>(<span class="ruby-node">&quot;Your expired certificate will be located at: #{new_expired_cert_path}&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sign" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">sign</span><span
                                class="method-args">(cert_file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="sign-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 290</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sign</span>(<span class="ruby-identifier">cert_file</span>)
  <span class="ruby-identifier">cert</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">cert_file</span>
  <span class="ruby-identifier">cert</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">cert</span>

  <span class="ruby-identifier">permissions</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">cert_file</span>).<span class="ruby-identifier">mode</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0o777</span>

  <span class="ruby-identifier">issuer_cert</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:issuer_cert</span>]
  <span class="ruby-identifier">issuer_key</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>]

  <span class="ruby-identifier">cert</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span>.<span class="ruby-identifier">sign</span> <span class="ruby-identifier">cert</span>, <span class="ruby-identifier">issuer_key</span>, <span class="ruby-identifier">issuer_cert</span>

  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">cert</span>, <span class="ruby-identifier">cert_file</span>, <span class="ruby-identifier">permissions</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-valid_email-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">valid_email?</span><span
                                class="method-args">(email)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="valid_email-3F-source">
            <pre><span class="ruby-comment"># File rubygems/commands/cert_command.rb, line 321</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">valid_email?</span>(<span class="ruby-identifier">email</span>)
  <span class="ruby-comment"># It&#39;s simple, but is all we need</span>
  <span class="ruby-identifier">email</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\A.+@.+\z/</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

